package junit.com.cpi.cornpp.user.dao;

import junit.framework.TestCase;
import KC.ModSegApp.AplicacionApp;
import KC.ModSegApp.UsuarioApp;

import com.cpi.cornpp.user.dao.UserDAO;
import com.cpi.cornpp.user.dto.UserDTO;
import com.cpi.cornpp.user.exception.UserException;

/**
 * JUnit UserDAOTest
 * @author Edgar Joao
 *
 */
public class UserDAOTest extends TestCase {

	/**Valid User */
	private static final String VALID_USER = "jrivas";
	/**Valid Password */
	private static final String VALID_PASSWORD = "clodoaldo";
		
	UsuarioApp usuario;
	UserDAO userDAO;
	UserDTO userDTO;
	AplicacionApp aplicacion;	
	
	public UserDAOTest(String name) {
		super(name);
	}

	protected void setUp() throws Exception {
		super.setUp();		
		this.usuario = new UsuarioApp();
		this.userDAO = new UserDAO();
		this.userDTO = new UserDTO();
	}

	protected void tearDown() throws Exception {
		super.tearDown();
	}
	
	public void testLoginUserDAO() {
		
		userDTO.setUsrId(VALID_USER);
		userDTO.setPassword(VALID_PASSWORD);
		
		try {		
			System.out.println(userDAO.loginUser(userDTO).getNombre());			
			assertTrue(userDAO.loginUser(userDTO).getLogin().length()> 0);
		} catch (UserException e) {
			fail(e.getMessage());
		}
	}

}
